package cn.edu.cug.dao;

import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class TestService {
    @Autowired



    public void test() throws IOException {

        Resource jdbcResour = new ClassPathResource("/dbconfig.properties");
        Properties props = PropertiesLoaderUtils.loadProperties(jdbcResour);



        System.out.println(props.getProperty("mysql_url"));

//        try {
//            BasicDataSource ds = new BasicDataSource();
//
//            ds.setDriverClassName("org.postgresql.Driver");
//            ds.setUrl("jdbc:postgresql://10.10.1.1:5432/gis_shapefile");
//            ds.setUsername("postgres");
//            ds.setPassword("postgres");
//
//
//            Connection connection = ds.getConnection();
//            Statement statement = connection.createStatement();
//            ResultSet resultSet = statement.executeQuery("select * from ne_110m_land");
//
//            System.out.println("Hello From SQL");
//
//            while(resultSet.next()){
//                String test1 = resultSet.getString(2);
//                System.out.println("Length: "+test1.length());
//                System.out.println(test1);
//            }
//
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
    }

    public static void main(String args[]) throws IOException {
        TestService testService = new TestService();
        testService.test();
    }
}
